package com.anlu.base.common.log;

import com.anlu.base.admin.api.feign.RemoteLogService;
import com.anlu.base.common.log.aspect.SysLogAspect;
import com.anlu.base.common.log.config.PigLogProperties;
import com.anlu.base.common.log.event.SysLogListener;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;

@EnableAsync
@Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties(PigLogProperties.class)
@ConditionalOnProperty(value = "security.log.enabled",matchIfMissing = true)
public class LogAutoConfiguration {

    @Bean
    public SysLogListener sysLogListener(PigLogProperties logProperties, RemoteLogService remoteLogService){
        return new SysLogListener(remoteLogService,logProperties);
    }

    @Bean
    public SysLogAspect sysLogAspect() {
        return new SysLogAspect();
    }



}
